package com.touchstone.synchdata.service.impl;

import com.touchstone.synchdata.dao.mysql.UserMapper;
import com.touchstone.synchdata.entity.mssql.Account;
import com.touchstone.synchdata.entity.mysql.User;
import com.touchstone.synchdata.service.IUserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Description :
 * @Author : hunter
 * @Date: 2020-06-23 11:26
 * @Version: 1.0
 **/
@Slf4j
@Service
public class UserServiceImpl implements IUserService {

    @Resource
    private UserMapper userMapper;

    @Override
    public List<User> listUsers() {
        List<User> users = userMapper.selectAll();
        log.info("查询MySQL所有用户：{}", users);
        return users;
    }

    @Override
    public int batchSave(List<User> users) {
        int record = 0;
        if (users.size() > 0) {
            record = userMapper.batchInsert(users);
            log.info("批量新增用户：【{}】", users);
        }
        return record;
    }
}
